/*
 * @Descripttion : switch
 * @Author       : QianFox Team
 * @Date         : 2022-03-03 08:59:15
 * @LastEditors  : QianFox Team
 * @LastEditTime : 2022-06-01 10:05:57
 */

function Switch() {
    this.HANDLE = '.foxui-switch:not(.is-disabled)';
    this.INPUT = '.foxui-switch-input';
}

Switch.prototype._init = function () {
    let that = this;
    $(document).on('click', this.HANDLE, function () {
        let $this = $(this),
            $input = $this.find(that.INPUT),
            isChecked = $this.is('.is-checked');
        if (isChecked) {
            $this.removeClass('is-checked');
            $input.prop('checked', false);
        } else {
            $this.addClass('is-checked');
            $input.prop('checked', true);
        }
    });
};

let switchs = new Switch();

export { switchs };
